/***************************************************************************
 *   Copyright (C) 2008 by Eduardo Gurgel Pinho                            *
 *   edgurgel@gmail.com                                                    *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 3 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
***************************************************************************/

#ifndef __WINDOW_H__
#define __WINDOW_H__

#include "common/input.h"
#include "common/scene.h"
#include "common/grid.h"
#include "common/image.h"
#include "raytracing/raytracer.h"

#include <QMainWindow>
#include <QTime>

class QDockWidget;
class Action;
class QMenu;
class QMenuBar;
class QStatusBar;
class QToolBar;
class QFile;
class QString;
class QTimer;
class QPushButton;
class QProgressBar;

namespace Ui {
	class Main_Widget;
	class Scene_Tree;
	class Scene_Panel;
	class Object_Panel;
	class Material_Panel;
	class Raytracer_Panel;
	class Camera_Panel;
	class Render_Thread;
	class Qtimage;
		
class Window: public QMainWindow {
	Q_OBJECT
			
public:
	Window(void);
	~Window(void);
	
public slots:
		
signals:
	void material_selected(Sirat::Material::Material* _material);
private slots:
	void new_file(void);
	void open_file(void);
	void save_file(void);
	void save_as_file(void);
	void close_file(void);
	void render(void);
	void stop_render(void);
	void picking(int,int);
	void render_end(void);
	void update_progress(void);
	
signals:
	void image_rendered(QImage*);
	void set_clear(void);

	
private:
	void init(void);
	void create_toolbar(void);
	void create_dock_widgets(void);
	void create_menu(void);
	void create_connections(void);
	
	void set_raytracer(Sirat::Ray_Tracing::Raytracer* _raytracer);
	void set_scene(Sirat::Common::Scene* _scene);
	
	QPushButton* render_button;
	QPushButton* stop_button;
	
	/* Menubar Actions */
	QAction* actionNew;
	QAction* actionOpen;
	QAction* actionClose;
	QAction* actionExit;
	QAction* actionSave;
	QAction* actionSaveas;
	QAction* actionScene_Tree;
	QAction* actionScene_Panel;
	QAction* actionObject_Panel;
	QAction* actionMaterial_Panel;
	QAction* actionRaytracer_Panel;
	QAction* actionCamera_Panel;
	
	QToolBar* toolbar;
	QMenuBar* menubar;
	QMenu* menuFile;
	QMenu* menuTools;
	QStatusBar* statusbar;
	QProgressBar* progressbar;
	
	QDockWidget* dock_scene_tree;
	QDockWidget* dock_scene_panel;
	QDockWidget* dock_raytracer_panel;
	QDockWidget* dock_object_panel;
	QDockWidget* dock_material_panel;
	QDockWidget* dock_camera_panel;
	
	Scene_Tree* scene_tree;
	Raytracer_Panel* raytracer_panel;
	Object_Panel* object_panel;
	Material_Panel* material_panel;
	Scene_Panel* scene_panel;
	Camera_Panel* camera_panel;
	Main_Widget* main_widget;
	
	bool file;
	QString current_filename;
	Sirat::Common::Image* outputfile;
	
	// Sirat Interface
	Sirat::Common::Input input;
	Sirat::Ray_Tracing::Raytracer* raytracer;
	Sirat::Common::Camera* camera;
	Sirat::Common::Scene* scene;
	
	// Need a comment
	Sirat::Ray_Tracing::Raytracer* raytracer_rendering;
	
	QTime render_timer;
	QTimer* progress_timer;
	Render_Thread* render_thread;
	
};

}

#endif
